Button
A button that can be pressed by the user. Event handlers can be used to trap mouse, keyboard and other events. It is typically rendered as a grey outset rectangle. You can specify the label of the button using the label attribute or by placing content inside the button.
Example:
<button label="Press Me"
oncommand="alert('You pressed me!'); return false;"/>
Attributes:
Attributes inherited from XUL Element
This should be set to a letter that is used as a shortcut key. This letter should be one of the characters that appears in the label text for the button. This letter will typically be drawn underlined, although this behavior will be platform and skin specific. When the user presses ALT (or a similar key that varies on each platform) and the access key, the button will be activated from anywhere in the window.
Indicates whether the button is checked or not.
Set to an id of a command element that is being observed by the element.
If the label of the button is too small to fit in its given space, the text will be cropped on the side specified by the crop attribute. An ellipsis will be placed in place of the cropped text. If the box direction is right to left (rtl), the cropping is reversed.
- start: The text will be cropped on its left side.
- end: The text will be cropped on its right side.
- left: (Deprecated) The text will be cropped on its left side.
- right: (Deprecated) The text will be cropped on its right side.
- center: The text will be cropped on both sides.
- none: The text will be not be cropped using an ellipsis. However, the text will simply be cut off if it is too large. The side depends on the CSS text alignment.
Specifies which side of the button's label that its image is placed.
- ltr: The image appears to the left or above the label.
- rtl: The image appears to the right or below the label.
If this attribute is set to true, the button is disabled. This is usually drawn with the text in grey. If the button is disabled, the function of the button cannot be performed. Leave the attribute out entirely for a regular enabled button.
The type of the button. This should be set to create a special button in a dialog box. The following values can be used in the list:
- accept: The OK button, which will accept the changes when pressed.
- cancel: The cancel button which will cancel the operation.
- help: A help button for displaying help about the dialog.
- disclosure: A button to show more information. This might be a button or a disclosure triangle.
Buttons with the same value for their group attribute are put into the same group. Only one button from each group can be checked at a time. If one is checked, the others are unchecked.
The URL of the image to appear on the button. If this is attribute is left out, no image appears. The position of the image is determined by the dir and orient attributes.
The label that will appear on the button. If this is left out, no text appears.
Along with the dir attribute, the orient attribute is used to indicate where the button's image appears in relation to the the label.
- horizontal: The image appears to the left of the label if the dir attribute is 'ltr' or to the right of the text if the dir attribute is 'rtl'
- vertical: The image appears above the label if the dir attribute is 'ltr' or below the text if the dir attribute is 'rtl'
The type of button. If this attribute is not present, a normal button is created. Leave the attribute out for a normal button.
- checkbox: This type of button can be in two states. The user can click the button to switch between the states. This is not the same as a checkbox because it looks like a button. The off state is displayed like a regular button and the on state is displayed like a pressed button.
- menu: Set the type attribute to the value 'menu' to create a button with a menu popup. Place a menupopup element inside the button in this case.
- menu-button: You can also use the value 'menu-button' to create a button with a menu. This second value will typically cause the button to be displayed with an arrow to the side indicating that a menu is present. This type of button is used for Mozilla's back and forward buttons.
- radio: The button acts like a radio button. Only one button in the group can be on a once.
A value associated with the button. You may use it in a script for your own purposes.
Properties and Methods:
Properties and Methods inherited from XUL Element
This should be set to a letter that is used as a shortcut key. This letter should be one of the characters that appears in the label text for the button. This letter will typically be drawn underlined, although this behavior will be platform and skin specific. When the user presses ALT (or a similar key that varies on each platform) and the access key, the button will be activated from anywhere in the window.
Gets and sets the value of the autoCheck attribute.
If the focus is on the element, it is removed. The focus is not automatically placed on any other element. Essentially, this is used to call the onblur handler.
Gets and sets the value of the checkState attribute.
Gets and sets the value of the checked attribute.
Set to an id of a command element that is being observed by the element.
If the label of the button is too small to fit in its given space, the text will be cropped on the side specified by the crop attribute. An ellipsis will be placed in place of the cropped text. If the box direction is right to left (rtl), the cropping is reversed.
- start: The text will be cropped on its left side.
- end: The text will be cropped on its right side.
- left: (Deprecated) The text will be cropped on its left side.
- right: (Deprecated) The text will be cropped on its right side.
- center: The text will be cropped on both sides.
- none: The text will be not be cropped using an ellipsis. However, the text will simply be cut off if it is too large. The side depends on the CSS text alignment.
Gets and sets the value of the dir attribute.
Gets and sets the value of the dlgType attribute.
Executes the associated command.
Assigns the focus to the element, if it can accept the focus. The onfocus handler is called.
Gets and sets the value of the group attribute.
The URL of the image to appear on the button. If this is attribute is left out, no image appears. The position of the image is determined by the dir and orient attributes.
The label that will appear on the button. If this is left out, no text appears.
Gets and sets the value of the open attribute.
Gets and sets the value of the orient attribute.
Gets and sets the value of the type attribute.
A value associated with the button. You may use it in a script for your own purposes.